﻿//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1998-2024 Glodon Company Limited.
//
// Licensed under the MIT License
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the “Software”),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//////////////////////////////////////////////////////////////////////////////
#pragma once

#include "GbmpDefines.h"
#include <string>
#include "GmInplaceEdit.h"
#include "GmCommunicationEventTypes.h"

namespace gcmp
{
    class GM_INPLACE_EDIT_EXPORT ICommunicationProtocolHeader
    {
    public:
        virtual ~ICommunicationProtocolHeader() {}

        static OwnerPtr<ICommunicationProtocolHeader> Create();
        //获取版本号
        virtual const std::wstring& GetVersion() const = 0;
        virtual bool SetVersion(const std::wstring& version) = 0;

        //获取功能类型
        virtual FunctionType GetFunctionType() const = 0;
        virtual bool SetFunctionType(FunctionType fType) = 0;

        //获取操作类型
        virtual OperationType GetOperationType() const = 0;
        virtual bool SetOperationType(OperationType oType) = 0;

        //获取是否存在数据
        virtual bool HasData() const = 0;
        virtual bool SetHasData(bool hasData) = 0;
    };

    class CommunicationProtocolHeader : public ICommunicationProtocolHeader
    {
    public:
        virtual ~CommunicationProtocolHeader() {}
        CommunicationProtocolHeader(); 

        //获取版本号
        virtual const std::wstring& GetVersion() const override;
        virtual bool SetVersion(const std::wstring& version) override;

        //获取功能类型
        virtual FunctionType GetFunctionType() const override;
        virtual bool SetFunctionType(FunctionType fType) override;

        //获取操作类型
        virtual OperationType GetOperationType() const override;
        virtual bool SetOperationType(OperationType oType) override;

        //获取是否存在数据
        virtual bool HasData() const override;
        virtual bool SetHasData(bool hasData) override;
    private:
        std::wstring m_version;
        FunctionType m_functionType;
        OperationType m_operationType;
        bool m_hasData;
    };
}
